// var i;
// var c = cc._decorator;
// var s = c.ccclass;
// var l = c.property;
// var u = c.inspector;
// var d = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.txt_toast = null;
//         t.anm_toast = null;
//         return t;
//     }
//     __extends(t, e);
//     t.prototype.show = function (e) {
//         this.node.active = !0;
//         this.txt_toast.string = e;
//         this.node.width = e.length * this.txt_toast.fontSize + 100;
//         this.anm_toast.play();
//         this.anm_toast.off(cc.Animation.EventType.FINISHED, this._complete, this);
//         this.anm_toast.on(cc.Animation.EventType.FINISHED, this._complete, this);
//     };
//     t.prototype._complete = function () {
//         this.node.active = !1;
//     };
//     __decorate([l(cc.Label)], t.prototype, "txt_toast", void 0);
//     __decorate([l(cc.Animation)], t.prototype, "anm_toast", void 0);
//     return __decorate([s], t);
// })(cc.Component);
// exports.default = d;



// const { ccclass, property, inspector } = cc._decorator;

// /**
//  * UI_Toast 类
//  * 建议类名: ToastUI
//  */
// @ccclass
// export default class UI_Toast extends cc.Component {
//     /**
//      * 显示提示文本的标签
//      * 建议变量名: toastLabel
//      */
//     @property(cc.Label)
//     public txt_toast: cc.Label = null;

//     /**
//      * 提示动画
//      * 建议变量名: toastAnimation
//      */
//     @property(cc.Animation)
//     public anm_toast: cc.Animation = null;

//     /**
//      * 显示提示信息
//      * @param message 提示信息内容
//      * 建议方法名: displayToast
//      */
//     public show(message: string): void {
//         this.node.active = true;
//         this.txt_toast.string = message;
//         this.node.width = message.length * this.txt_toast.fontSize + 100;
//         this.anm_toast.play();
//         this.anm_toast.off(cc.Animation.EventType.FINISHED, this._complete, this);
//         this.anm_toast.on(cc.Animation.EventType.FINISHED, this._complete, this);
//     }

//     /**
//      * 动画完成后的回调函数
//      * 建议方法名: onAnimationComplete
//      */
//     private _complete(): void {
//         this.node.active = false;
//     }
// }

const { ccclass, property, inspector } = cc._decorator;

/**
 * UI_Toast 类
 * 建议类名: ToastUI
 */
@ccclass
export default class ViewToast extends cc.Component {
    /**
     * 显示提示文本的标签
     * 建议变量名: toastLabel
     */
    @property(cc.Label)
    public txt_toast: cc.Label = null;

    /**
     * 提示动画
     * 建议变量名: toastAnimation
     */
    @property(cc.Animation)
    public anm_toast: cc.Animation = null;

    /**
     * 显示提示信息
     * @param message 提示信息内容
     * 建议方法名: displayToast
     */
    public show(message: string): void {
        this.node.active = true;
        this.txt_toast.string = message;
        this.node.width = message.length * this.txt_toast.fontSize + 100;
        this.anm_toast.play();
        this.updateAnimationListener();
    }

    /**
     * 更新动画完成事件的监听器
     * 建议方法名: updateAnimationListener
     */
    private updateAnimationListener(): void {
        this.anm_toast.off(cc.Animation.EventType.FINISHED, this.onAnimationComplete, this);
        this.anm_toast.on(cc.Animation.EventType.FINISHED, this.onAnimationComplete, this);
    }

    /**
     * 动画完成后的回调函数
     * 建议方法名: onAnimationComplete
     */
    private onAnimationComplete(): void {
        this.node.active = false;
    }
}